<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if(@$_GET['action']=='new'){
    $_html=array();
    $_html['title']=$_POST['title'];
    $_html['author']=$_POST['author'];
    $_html['content']=$_POST['content'];
   $_conn=mysql_connect('localhost','root','') or die(mysql_error());
   mysql_select_db('new',$_conn) or die(mysql_error());
   mysql_query("SET NAMES UTF8") or die(mysql_error());
   mysql_query("INSERT INTO list (title,content,author,date) VALUES('{$_html['title']}','{$_html['content']}','{$_html['author']}',NOW())") or die(mysql_error());
   if(mysql_affected_rows()==1){
        mysql_close();
      echo "<script type='text/javascript'>alert('添加成功!');location.href='index.php';</script>";
     
   }else{
       mysql_close(); 
      echo "<script type='text/javascript'>alert('添加失败!');history.back();</script>";
       
   }
}

?>
<html>
   <head>
    <title>新闻发布</title>   
     <link rel="stylesheet" type="html/css" href="style/index.css"/>
   </head> 
 <body>
    <div id="new">
        <p>新闻发布</p>
    </div> 
     <div id="post">
        <form method="post" action="?action=new">
            <dl>
           <dd>标题:<input type="text" name="title" class="title"/></dd>
           <dd>作者:<input type="text" name="author" class="author" /></dd>
           <dd>内容:<textarea name="content" class="content"></textarea></dd>
           <dd><input type="submit" name="submit" value="提交" class="submit">  <a href="look.php" class="look">查看</dd>
            </dl> 
           </form> 
         
         
     </div>
 </body>   
    
</html>
